package com.day03;

/**
 * 1.定义形状类；属性：周长；方法：计算周长
 * 2.定义长方形
 * 3.定义圆形
 */
public class AbstractExercise {
    public static void main(String[] args) {
        Shape s1 = new Rectangle(4.0d, 2.0d);
        Shape s2 = new Circle(3.0d);
        System.out.println(s1.calculationCircum()+":"+s2.calculationCircum());
    }

}

abstract class Shape {

    public double circum;

    public abstract double calculationCircum();

}

class Rectangle extends Shape {

    private double a;
    private double b;

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public Rectangle(double a, double b) {
        this.a = a;
        this.b = b;
    }

    public double calculationCircum() {
        circum = (a + b) * 2;
        return circum;
    }
}

class Circle extends Shape {

    private double c;

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }

    public Circle(double c) {
        this.c = c;
    }

    public double calculationCircum() {
        circum = 3.14d * c * 2;
        return circum;
    }
}
